﻿using System;
using System.Web.UI;
using FranceTriple.Dal;

namespace TeamFranceTriple
{
    public partial class Calendar : BaseUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ViewState["EventCalendar1"] != null)
                EventCalendar1.SelectedDate = DateTime.Parse(ViewState["EventCalendar1"].ToString());
            SendButton.PostBackUrl = String.Format("~/{0}/eventlist",ThisMaster.Requester.Culture);
        }

        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (Session["AnonymousID"] == null)
            {
                EventCategoryRadioButtonList.Visible = true;
                EventCalendar1.Enabled = true;
                SendButton.Visible = true;
            }

            //TODO : debug and uncomment
            //EventCategory ec;
            //if (ViewState["EventCalendar1"] != null)
            //{
            //    if (EventCategoryRadioButtonList.SelectedValue != String.Empty)
            //    {
            //        ec = EventDal.GetEventCategory(Int32.Parse(EventCategoryRadioButtonList.SelectedValue));
            //        EventCalendar1.SelectedDayStyle.BackColor = System.Drawing.Color.FromArgb(
            //            Convert.ToInt32(ec.BackColorEventCategory.Substring(0, 2), 16),
            //            Convert.ToInt32(ec.BackColorEventCategory.Substring(2, 2), 16),
            //            Convert.ToInt32(ec.BackColorEventCategory.Substring(4, 2), 16));
            //        EventCalendar1.SelectedDayStyle.ForeColor = System.Drawing.Color.FromArgb(
            //            Convert.ToInt32(ec.ColorEventCategory.Substring(0, 2), 16),
            //            Convert.ToInt32(ec.ColorEventCategory.Substring(2, 2), 16),
            //            Convert.ToInt32(ec.ColorEventCategory.Substring(4, 2), 16));
            //    }
            //    EventCalendar1.SelectedDate = DateTime.Parse(ViewState["EventCalendar1"].ToString());
            //}

        }

        protected void Calendar1_SelectionChanged(object sender, EventArgs e)
        {
            ViewState["EventCalendar1"] = EventCalendar1.SelectedDate;
        }

        protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}